
//
//  LYRetestCell.m
//  SelectCity
//
//  Created by liuyan on 2019/3/20.
//  Copyright © 2019年 liuyan. All rights reserved.
//

#import "LYRetestCell.h"

@interface LYRetestCell()

@property (nonatomic, strong) UIView *backView;
@property (nonatomic, strong) UIImageView *iconImage;
@property (nonatomic, strong) UILabel *nameLabel;
//职位或公司
@property (nonatomic, strong) UILabel *positionLabel;
//个人信息或岗位
@property (nonatomic, strong) UILabel *personInfoLabel;
//详细信息背景
@property (nonatomic, strong) UIView *infoBackView;

@property (nonatomic, strong) UILabel *contactGreetLabel;
@property (nonatomic, strong) UILabel *contactTimeLabel;
@property (nonatomic, strong) UILabel *contactMobileLabel;
@property (nonatomic, strong) UILabel *contactNameLabel;
@property (nonatomic, strong) UILabel *contactAddressLabel;
//备注信息
@property (nonatomic, strong) UILabel *contactNoteLabel;

@end

@implementation LYRetestCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initUI];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

#pragma mark - InitSubViews
- (void)initUI {
    self.backgroundColor = [UIColor clearColor];
    
    self.backView = [[UIView alloc] initWithFrame:CGRectMake(8, 5, WIDTH - 16, 230)];
    self.backView.backgroundColor = THEMECOLOR_OF_ORANGE;
    self.backView.layer.cornerRadius = 5;
    self.backView.layer.masksToBounds = YES;
    [self.contentView addSubview:self.backView];
    
    self.iconImage = [UIToolsControl initImageViewWithFrame:CGRectMake(10, 15, 40, 40) imageName:@"header_bg"];
    self.iconImage.contentMode = UIViewContentModeScaleAspectFill;
    self.iconImage.layer.cornerRadius = 20;
    self.iconImage.layer.masksToBounds = YES;
    self.iconImage.backgroundColor = THEMECOLOR_OF_GRAY;
    [self.backView addSubview:self.iconImage];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.iconImage.right +8, 15, (self.backView.width-70)*0.5, 20)];
    self.nameLabel.textColor = COLOR_OF_WHITE;
    self.nameLabel.font = FontBold(Font_15);
//    self.nameLabel.text = @"罗志伟";
    [self.backView addSubview:self.nameLabel];
    
    self.positionLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.iconImage.right +80, 15, self.backView.width-100-self.iconImage.right, 20)];
    self.positionLabel.textColor = COLOR_OF_WHITE;
    self.positionLabel.font = FontBold(Font_15);
//    self.positionLabel.text = @"大渝网 ceo";
    self.positionLabel.textAlignment = NSTextAlignmentRight;
    [self.backView addSubview:self.positionLabel];
    
    //个人信息
    self.personInfoLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.nameLabel.left,self.nameLabel.bottom,self.backView.width - self.nameLabel.left - 8, 20)];
    self.personInfoLabel.textColor = COLOR_OF_WHITE;
    self.personInfoLabel.font = Font(Font_13);
//    self.personInfoLabel.text = @"男 | 27岁 | 本科 | 5年";
    [self.backView addSubview:self.personInfoLabel];
    
    self.infoBackView = [[UIView alloc] initWithFrame:CGRectMake(10,70, self.backView.width - 20, 145)];
    self.infoBackView.backgroundColor = COLOR_OF_WHITE;
    self.infoBackView.layer.cornerRadius = 5;
    self.infoBackView.layer.masksToBounds = YES;
    [self.backView addSubview:self.infoBackView];
    
    self.contactGreetLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 8, self.infoBackView.width- 15, 20)];
    self.contactGreetLabel.textColor = THEMECOLOR_OF_TEXT_333333;
    self.contactGreetLabel.font = Font(Font_13);
//    self.contactGreetLabel.text = @"李女士, 您好！看到你的简历适合我们公司的招聘条件";
    [self.infoBackView addSubview:self.contactGreetLabel];
    
    self.contactTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.contactGreetLabel.left,self.contactGreetLabel.bottom+5,self.contactGreetLabel.width, 20)];
    self.contactTimeLabel.textColor = THEMECOLOR_OF_TEXT_333333;
    self.contactTimeLabel.font = Font(Font_13);
//    self.contactTimeLabel.text = @"通知你 2019-03-20 10:00 来公司参加复试";
    [self.infoBackView addSubview:self.contactTimeLabel];
    
    self.contactMobileLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.contactTimeLabel.left,self.contactTimeLabel.bottom+5,self.contactTimeLabel.width, 20)];
    self.contactMobileLabel.textColor = THEMECOLOR_OF_TEXT_333333;
    self.contactMobileLabel.font = Font(Font_13);
//    self.contactMobileLabel.text = @"联系电话：13810624981";
    [self.infoBackView addSubview:self.contactMobileLabel];
    
    self.contactNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.contactMobileLabel.left,self.contactMobileLabel.bottom+5,self.contactMobileLabel.width, 20)];
    self.contactNameLabel.textColor = THEMECOLOR_OF_TEXT_333333;
    self.contactNameLabel.font = Font(Font_13);
//    self.contactNameLabel.text = @"联系人：李建华";
    [self.infoBackView addSubview:self.contactNameLabel];
    
    self.contactAddressLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.contactNameLabel.left, self.contactNameLabel.bottom, self.contactNameLabel.width, 40)];
    self.contactAddressLabel.textColor = THEMECOLOR_OF_TEXT_333333;
    self.contactAddressLabel.font = Font(Font_13);
    self.contactAddressLabel.numberOfLines = 0;
    self.contactAddressLabel.lineBreakMode = NSLineBreakByWordWrapping;
//    self.contactAddressLabel.text = @"面试地址：海淀区智造大街B座3层";
    [self.infoBackView addSubview:self.contactAddressLabel];
    
    self.contactNoteLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.contactAddressLabel.left,self.contactAddressLabel.bottom+5,self.contactAddressLabel.width, 20)];
    self.contactNoteLabel.textColor = COLOR_OF_WHITE;
    self.contactNoteLabel.font = Font(Font_13);
//    self.contactNoteLabel.text = @"备注：你到203室来一趟";
    self.contactNoteLabel.hidden = YES;
    [self.infoBackView addSubview:self.contactNoteLabel];
}

#pragma mark -- Data
- (void)setCompanyModel:(LYRetestCompanyModel *)companyModel {
    
}

- (void)setPeisonModel:(LYRetestPersonModel *)personModel {
    
}
- (void)reloadDataForPersonlModel:(PMineReexamineInviteModel *)model {
    if (model.hrInfoModel.avatar && model.hrInfoModel.avatar.length) {
        [self.iconImage sd_setImageWithURL:[NSURL URLWithString:model.hrInfoModel.avatar]];
    } else {
        self.iconImage.image = [UIImage imageNamed:@"header_bg"];
    }
    self.nameLabel.frame = CGRectMake(self.iconImage.right +8, 15, self.backView.width-50, 20);
    
    _nameLabel.text = model.company_name;
//    _positionLabel.text = [NSString stringWithFormat:@"%@ %@", model.company_name, model.hrInfoModel.position];
    _personInfoLabel.text = [NSString stringWithFormat:@"%@ %@ %@ / %@", model.hrInfoModel.name,  model.hrInfoModel.position, ((model.job_name&&model.job_name.length)?model.job_name:@""), ((model.job_wage&&model.job_wage.length)?model.job_wage:@"")];
//    _contactGreetLabel.text = model.notes;
    _contactGreetLabel.text = [NSString stringWithFormat:@"%@,您好,与您初步沟通后,与我们的岗位需求比较匹配", UD_GetOForK(isUserName)];
    _contactTimeLabel.text = [NSString stringWithFormat:@"通知您于 %@ 来公司参加复试", model.interviewTimeYYYYMMddHHmm];
    
    _contactMobileLabel.text = [NSString stringWithFormat:@"联系电话：%@", model.telephone];
    _contactNameLabel.text = [NSString stringWithFormat:@"联系人：%@", model.contact];
    _contactAddressLabel.text = [NSString stringWithFormat:@"面试地址：%@", model.address];
}
- (void)reloadDataForCompanyModel:(PMineReexamineInviteModel *)model {
    if (model.avatar && model.avatar.length) {
        [self.iconImage sd_setImageWithURL:[NSURL URLWithString:model.avatar]];
    } else {
        self.iconImage.image = [UIImage imageNamed:@"header_bg"];
    }
    
    _nameLabel.text = model.name;
    _positionLabel.text = [NSString stringWithFormat:@"面试：%@", model.job_title];
    _personInfoLabel.text = [NSString stringWithFormat:@"%@ | %@ | %@ | %@", ((model.sex_cn&&model.sex_cn.length)?model.sex_cn:@""), ((model.age&&model.age.length)?model.age:@""), ((model.education_cn&&model.education_cn.length)?model.education_cn:@""), ((model.experience_cn&&model.experience_cn.length)?model.experience_cn:@"")];
//    _contactGreetLabel.text = model.notes;
    _contactGreetLabel.text = [NSString stringWithFormat:@"%@,您好,与您初步沟通后，与我们的岗位需求比较匹配", model.name];
    _contactTimeLabel.text = [NSString stringWithFormat:@"通知您于 %@ 来公司参加复试", model.interview_date];
    
    _contactMobileLabel.text = [NSString stringWithFormat:@"联系电话：%@", model.telephone];
    _contactNameLabel.text = [NSString stringWithFormat:@"联系人：%@", model.contact];
    _contactAddressLabel.text = [NSString stringWithFormat:@"面试地址：%@", model.address];
}

@end
